unit SmallStruct.Script.ScriptObject;

interface

uses Classes,
  DB,
  atScript,
  Dialogs,
  SmallStruct.Database.TSSDataSet,
  SmallStruct.BusinessObject.TSSAdvancedBusinessObject;

type
  TSSObjectContainerSO = class(TatScripterLibrary)
  public
    procedure _AppendObject(AMachine: TatVirtualMachine);
    procedure _FindObject(AMachine: TatVirtualMachine);
    procedure _GetCount(AMachine: TatVirtualMachine);
    procedure _GetObjectByIndex(AMachine: TatVirtualMachine);
    procedure _GetObjectByName(AMachine: TatVirtualMachine);
    procedure _GetObjectName(AMachine: TatVirtualMachine);
    procedure _RemoveObjectAll(AMachine: TatVirtualMachine);
    procedure _RemoveObjectByIndex(AMachine: TatVirtualMachine);
    procedure _RemoveObjectByName(AMachine: TatVirtualMachine);
  public
    procedure Init; override;
  end;

  TSSRecordSO = class(TatScripterLibrary)
  public
    procedure _AppendValue(AMachine: TatVirtualMachine);
    procedure _GetBooleanValue(AMachine: TatVirtualMachine);
    procedure _GetCurrencyValue(AMachine: TatVirtualMachine);
    procedure _GetDateTimeValue(AMachine: TatVirtualMachine);
    procedure _GetDoubleValue(AMachine: TatVirtualMachine);
    procedure _GetIntegerValue(AMachine: TatVirtualMachine);
    procedure _GetStringValue(AMachine: TatVirtualMachine);
    procedure _GetValue(AMachine: TatVirtualMachine);
    procedure _GetValueCount(AMachine: TatVirtualMachine);
    procedure _GetValueName(AMachine: TatVirtualMachine);
    procedure _Destory(AMachine: TatVirtualMachine);
  public
    procedure Init; override;
  end;

  TSSDataSetSO = class(TatScripterLibrary)
  public
    procedure _GetBooleanValue(AMachine: TatVirtualMachine);
    procedure _GetCount(AMachine: TatVirtualMachine);
    procedure _GetCurrencyValue(AMachine: TatVirtualMachine);
    procedure _GetData(AMachine: TatVirtualMachine);
    procedure _GetDataByBookmark(AMachine: TatVirtualMachine);
    procedure _GetDataSet(AMachine: TatVirtualMachine);
    procedure _GetDateTimeValue(AMachine: TatVirtualMachine);
    procedure _GetDoubleValue(AMachine: TatVirtualMachine);
    procedure _GetFieldCount(AMachine: TatVirtualMachine);
    procedure _GetFieldName(AMachine: TatVirtualMachine);
    procedure _GetIntegerValue(AMachine: TatVirtualMachine);
    procedure _GetStringValue(AMachine: TatVirtualMachine);
    procedure _GetValue(AMachine: TatVirtualMachine);
    procedure _GetValueAverage(AMachine: TatVirtualMachine);
    procedure _GetValueMax(AMachine: TatVirtualMachine);
    procedure _GetValueMin(AMachine: TatVirtualMachine);
    procedure _GetValueSum(AMachine: TatVirtualMachine);
    procedure _IsBof(AMachine: TatVirtualMachine);
    procedure _IsEof(AMachine: TatVirtualMachine);
    procedure _SetFilter(AMachine: TatVirtualMachine);
    procedure _SetIndex(AMachine: TatVirtualMachine);
    procedure _Next(AMachine: TatVirtualMachine);
    procedure _Prior(AMachine: TatVirtualMachine);
    procedure _First(AMachine: TatVirtualMachine);
    procedure _Last(AMachine: TatVirtualMachine);
    procedure _Append(AMachine: TatVirtualMachine);
    procedure _Delete(AMachine: TatVirtualMachine);
    procedure _SetValue(AMachine: TatVirtualMachine);
    procedure _SetNull(AMachine: TatVirtualMachine);
    procedure _Save(AMachine: TatVirtualMachine);
    procedure _Destory(AMachine: TatVirtualMachine);
    procedure _Locate(AMachine: TatVirtualMachine);
    procedure _Edit(AMachine: TatVirtualMachine);
  public
    procedure Init; override;
  end;

  TSSDataModelSO = class(TatScripterLibrary)
  public
    procedure _AppendRecord(AMachine: TatVirtualMachine);
    procedure _ApplyModify(AMachine: TatVirtualMachine);
    procedure _CancelModify(AMachine: TatVirtualMachine);
    procedure _CloseDataModel(AMachine: TatVirtualMachine);
    procedure _DeleteRecord(AMachine: TatVirtualMachine);
    procedure _GetDataSet(AMachine: TatVirtualMachine);
    procedure _GetDataSource(AMachine: TatVirtualMachine);
    procedure _IsAutoOpen(AMachine: TatVirtualMachine);
    procedure _IsReadOnly(AMachine: TatVirtualMachine);
    procedure _OpenDataModel(AMachine: TatVirtualMachine);
    procedure _RefreshDataModel(AMachine: TatVirtualMachine);
  public
    procedure Init; override;
  end;

  TSSDatabaseDriverSO = class(TatScripterLibrary)
  public
    procedure _CommitTransaction(AMachine: TatVirtualMachine);
    procedure _ExecuteProcedure(AMachine: TatVirtualMachine);
    procedure _ExecuteSQL(AMachine: TatVirtualMachine);
    procedure _Query(AMachine: TatVirtualMachine);
    procedure _QueryByModifiable(AMachine: TatVirtualMachine);
    procedure _RollbackTransaction(AMachine: TatVirtualMachine);
    procedure _StartTransaction(AMachine: TatVirtualMachine);
    procedure _InitObject(AMachine: TatVirtualMachine);
  public
    procedure Init; override;
  end;

  TSSScriptBusinessObjectContextSO = class(TatScripterLibrary)
  public
    procedure _GetParameters(AMachine: TatVirtualMachine);
    procedure _GetDatabase(AMachine: TatVirtualMachine);
  public
    procedure Init; override;
  end;

implementation

uses
  SmallStruct.Core.TSSObjectContainer,
  SmallStruct.Tools,
  SmallStruct.Model.TSSADODataModel,
  SmallStruct.Database.TSSADODatabaseDriver,
  SmallStruct.BusinessObject.TSSScriptBusinessObject;

{ TSSRecordSO }

procedure TSSRecordSO.Init;
begin
  inherited;
  with Scripter.AddDelphiClass(TSSRecord) do
  begin
    DefineMethod('GetBooleanValue', 1, tkEnumeration, nil, _GetBooleanValue);
    DefineMethod('GetCurrencyValue', 1, tkVariant, nil, _GetCurrencyValue);
    DefineMethod('GetDateTimeValue', 1, tkVariant, nil, _GetDateTimeValue);
    DefineMethod('GetDoubleValue', 1, tkVariant, nil, _GetDoubleValue);
    DefineMethod('GetIntegerValue', 1, tkInteger, nil, _GetIntegerValue);
    DefineMethod('GetStringValue', 1, tkString, nil, _GetStringValue);
    DefineMethod('GetValue', 1, tkVariant, nil, _GetValue);
    DefineMethod('GetValueCount', 0, tkInteger, nil, _GetValueCount);
    DefineMethod('GetValueName', 1, tkString, nil, _GetValueName);
    DefineMethod('AppendValue', 2, tkNone, nil, _AppendValue);
    DefineMethod('Destory', 0, tkNone, nil, _Destory);
    //    Definemethod('Destory',0,tkNone,nil,_Destory);
  end;
end;

procedure TSSRecordSO._AppendValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSRecord(CurrentObject).AppendValue(GetInputArgAsString(0), GetInputArgAsString(1));
  end;
end;

procedure TSSRecordSO._Destory;
begin
  with AMachine do
  begin
    TSSRecord(CurrentObject).Destroy;
  end;
end;

procedure TSSRecordSO._GetBooleanValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSRecord(CurrentObject).GetBooleanValue(GetInputArgAsString(0)));
  end;
end;

procedure TSSRecordSO._GetCurrencyValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSRecord(CurrentObject).GetCurrencyValue(GetInputArgAsString(0)));
  end;
end;

procedure TSSRecordSO._GetDateTimeValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSRecord(CurrentObject).GetDateTimeValue(GetInputArgAsString(0)));
  end;
end;

procedure TSSRecordSO._GetDoubleValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSRecord(CurrentObject).GetDoubleValue(GetInputArgAsString(0)));
  end;
end;

procedure TSSRecordSO._GetIntegerValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSRecord(CurrentObject).GetIntegerValue(GetInputArgAsString(0)));
  end;
end;

procedure TSSRecordSO._GetStringValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSRecord(CurrentObject).GetStringValue(GetInputArgAsString(0)));
  end;
end;

procedure TSSRecordSO._GetValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSRecord(CurrentObject).GetValue(GetInputArgAsString(0)));
  end;
end;

procedure TSSRecordSO._GetValueCount(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSRecord(CurrentObject).GetValueCount);
  end;
end;

procedure TSSRecordSO._GetValueName(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSRecord(CurrentObject).GetValueName(GetInputArgAsInteger(0)));
  end;
end;

{ TSSDataSetSO }

procedure TSSDataSetSO.Init;
begin
  inherited;
  with Scripter.AddDelphiClass(TSSDataSet) do
  begin
    DefineMethod('GetBooleanValue', 1, tkEnumeration, nil, _GetBooleanValue);
    DefineMethod('GetCount', 0, tkInteger, nil, _GetCount);
    DefineMethod('GetCurrencyValue', 1, tkVariant, nil, _GetCurrencyValue);
    DefineMethod('GetDateTimeValue', 1, tkVariant, nil, _GetDateTimeValue);
    DefineMethod('GetDoubleValue', 1, tkVariant, nil, _GetDoubleValue);
    DefineMethod('GetIntegerValue', 1, tkInteger, nil, _GetIntegerValue);
    DefineMethod('GetStringValue', 1, tkString, nil, _GetStringValue);
    DefineMethod('GetValue', 1, tkVariant, nil, _GetValue);
    DefineMethod('GetDataSet', 0, tkClass, nil, _GetDataSet);
    DefineMethod('GetFieldCount', 0, tkInteger, nil, _GetFieldCount);
    DefineMethod('GetFieldName', 1, tkString, nil, _GetFieldName);
    DefineMethod('GetData', 0, tkClass, nil, _GetData);
    DefineMethod('GetDataByBookmark', 1, tkClass, nil, _GetDataByBookmark);
    DefineMethod('GetValueAverage', 1, tkVariant, nil, _GetValueAverage);
    DefineMethod('GetValueSum', 1, tkVariant, nil, _GetValueSum);
    DefineMethod('GetValueMax', 1, tkVariant, nil, _GetValueMax);
    DefineMethod('GetValueMin', 1, tkVariant, nil, _GetValueMin);
    DefineMethod('IsBof', 0, tkEnumeration, nil, _IsBof);
    DefineMethod('IsEof', 0, tkEnumeration, nil, _IsEof);
    DefineMethod('SetFilter', 1, tkNone, nil, _SetFilter);
    DefineMethod('SetIndex', 1, tkNone, nil, _SetIndex);
    DefineMethod('Next', 0, tkNone, nil, _Next);
    DefineMethod('Prior', 0, tkNone, nil, _Prior);
    DefineMethod('First', 0, tkNone, nil, _First);
    DefineMethod('Last', 0, tkNone, nil, _Last);
    DefineMethod('Append', 0, tkNone, nil, _Append);
    DefineMethod('Delete', 0, tkNone, nil, _Delete);
    DefineMethod('SetValue', 2, tkNone, nil, _SetValue);
    DefineMethod('SetNull', 1, tkNone, nil, _SetNull);
    DefineMethod('Save', 0, tkNone, nil, _Save);
    Definemethod('Destory', 0, tkNone, nil, _Destory);
    Definemethod('Locate', 2, tkEnumeration, nil, _Locate);
    DefineMethod('Edit', 0, tkNone, nil, _Edit);
    //    DefineMethod('IsBof', 0, tkEnumeration, nil, _IsBof);
  end;
end;

procedure TSSDataSetSO._Append(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSDataSet(CurrentObject).Append;
  end;
end;

procedure TSSDataSetSO._Delete(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSDataSet(CurrentObject).Delete;
  end;
end;

procedure TSSDataSetSO._Destory(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSDataSet(CurrentObject).Destroy;
  end;
end;

procedure TSSDataSetSO._Edit(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSDataSet(CurrentObject).edit;
  end;
end;

procedure TSSDataSetSO._First(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSDataSet(CurrentObject).First;
  end;
end;

procedure TSSDataSetSO._GetBooleanValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).GetBooleanValue(GetInputArgAsString(0)));
  end;
end;

procedure TSSDataSetSO._GetCount(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).GetCount);
  end;
end;

procedure TSSDataSetSO._GetCurrencyValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).GetCurrencyValue(GetInputArgAsString(0)));
  end;
end;

procedure TSSDataSetSO._GetData(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(Integer(TSSDataSet(CurrentObject).GetData.GetObjectInstance));
  end;
end;

procedure TSSDataSetSO._GetDataByBookmark(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(Integer(TSSDataSet(CurrentObject).GetData(TStringList(GetInputArgAsInteger(0))).GetObjectInstance));
  end;
end;

procedure TSSDataSetSO._GetDataSet(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(Integer(TSSDataSet(CurrentObject).GetDataSet));
  end;
end;

procedure TSSDataSetSO._GetDateTimeValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).GetDateTimeValue(GetInputArgAsString(0)));
  end;
end;

procedure TSSDataSetSO._GetDoubleValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).GetDoubleValue(GetInputArgAsString(0)));
  end;
end;

procedure TSSDataSetSO._GetFieldCount(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).GetFieldCount);
  end;
end;

procedure TSSDataSetSO._GetFieldName(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).GetFieldName(GetInputArgAsInteger(0)));
  end;
end;

procedure TSSDataSetSO._GetIntegerValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).GetIntegerValue(GetInputArgAsString(0)));
  end;
end;

procedure TSSDataSetSO._GetStringValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).GetStringValue(GetInputArgAsString(0)));
  end;
end;

procedure TSSDataSetSO._GetValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).GetValue(GetInputArgAsString(0)));
  end;
end;

procedure TSSDataSetSO._GetValueAverage(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).GetValueAverage(GetInputArgAsString(0)));
  end;
end;

procedure TSSDataSetSO._GetValueMax(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).GetValueMax(GetInputArgAsString(0)));
  end;
end;

procedure TSSDataSetSO._GetValueMin(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).GetValueMin(GetInputArgAsString(0)));
  end;
end;

procedure TSSDataSetSO._GetValueSum(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).GetValueSum(GetInputArgAsString(0)));
  end;
end;

procedure TSSDataSetSO._IsBof(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).IsBof);
  end;
end;

procedure TSSDataSetSO._IsEof(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).IsEof);
  end;
end;

procedure TSSDataSetSO._Last(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSDataSet(CurrentObject).Last;
  end;
end;

procedure TSSDataSetSO._Locate(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).Locate(GetInputArgAsString(0), GetInputArg(1)));
  end;
end;
{
  with AMachine do
  begin
    ReturnOutputArg(TSSDataSet(CurrentObject).IsEof);
  end;
}

procedure TSSDataSetSO._Next(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSDataSet(CurrentObject).Next;
  end;
end;

procedure TSSDataSetSO._Prior(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSDataSet(CurrentObject).Prior;
  end;
end;

procedure TSSDataSetSO._Save(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSDataSet(CurrentObject).Save;
  end;
end;

procedure TSSDataSetSO._SetFilter(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSDataSet(CurrentObject).SetFilter(GetInputArgAsString(0));
  end;
end;

procedure TSSDataSetSO._SetIndex(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSDataSet(CurrentObject).SetIndex(GetInputArgAsString(0));
  end;
end;

procedure TSSDataSetSO._SetNull(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSDataSet(CurrentObject).SetNull(GetInputArgAsString(0));
  end;
end;

procedure TSSDataSetSO._SetValue(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSDataSet(CurrentObject).SetValue(GetInputArgAsString(0), GetInputArg(1));
  end;
end;

{ TSSObjectContainerSO }

procedure TSSObjectContainerSO.Init;
begin
  inherited;
  with Scripter.AddDelphiClass(TSSObjectContainer) do
  begin
    DefineMethod('FindObject', 1, tkInteger, nil, _FindObject);
    DefineMethod('GetCount', 0, tkInteger, nil, _GetCount);
    DefineMethod('GetObjectByIndex', 1, tkClass, nil, _GetObjectByIndex);
    DefineMethod('GetObjectByName', 1, tkClass, nil, _GetObjectByName);
    DefineMethod('GetObjectName', 1, tkString, nil, _GetObjectName);
    DefineMethod('AppendObject', 2, tkNone, nil, _AppendObject);
    DefineMethod('RemoveObjectByIndex', 1, tkNone, nil, _RemoveObjectByIndex);
    DefineMethod('RemoveObjectByName', 1, tkNone, nil, _RemoveObjectByName);
    DefineMethod('RemoveObjectAll', 0, tkNone, nil, _RemoveObjectAll);
  end;
end;

procedure TSSObjectContainerSO._AppendObject(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSObjectContainer(CurrentObject).AppendObject(GetInputArgAsString(0), TComponent(GetInputArgAsInteger(1)));
  end;
end;

procedure TSSObjectContainerSO._FindObject(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSObjectContainer(CurrentObject).FindObject(GetInputArgAsString(0)));
  end;
end;

procedure TSSObjectContainerSO._GetCount(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSObjectContainer(CurrentObject).GetCount);
  end;
end;

procedure TSSObjectContainerSO._GetObjectByIndex(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(Integer(TSSObjectContainer(CurrentObject).GetObject(GetInputArgAsInteger(0))));
  end;
end;

procedure TSSObjectContainerSO._GetObjectByName(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(Integer(TSSObjectContainer(CurrentObject).GetObject(GetInputArgAsString(0))));
  end;
end;

procedure TSSObjectContainerSO._GetObjectName(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSObjectContainer(CurrentObject).GetObjectName(GetInputArgAsInteger(0)));
  end;
end;

procedure TSSObjectContainerSO._RemoveObjectAll(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSObjectContainer(CurrentObject).RemoveObject;
  end;
end;

procedure TSSObjectContainerSO._RemoveObjectByIndex(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSObjectContainer(CurrentObject).RemoveObject(GetInputArgAsInteger(0));
  end;
end;

procedure TSSObjectContainerSO._RemoveObjectByName(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSObjectContainer(CurrentObject).RemoveObject(GetInputArgAsString(0));
  end;
end;

{ TSSDataModelSO }

procedure TSSDataModelSO.Init;
begin
  inherited;
  with Scripter.AddDelphiClass(TSSADODataModel) do
  begin
    DefineMethod('GetDataSet', 0, tkClass, nil, _GetDataSet);
    DefineMethod('GetDataSource', 0, tkClass, nil, _GetDataSource);
    DefineMethod('IsAutoOpen', 0, tkEnumeration, nil, _IsAutoOpen);
    DefineMethod('IsReadOnly', 0, tkEnumeration, nil, _IsReadOnly);
    DefineMethod('AppendRecord', 0, tkNone, nil, _AppendRecord);
    DefineMethod('ApplyModify', 0, tkNone, nil, _ApplyModify);
    DefineMethod('CancelModify', 0, tkNone, nil, _CancelModify);
    DefineMethod('CloseDataModel', 0, tkNone, nil, _CloseDataModel);
    DefineMethod('DeleteRecord', 0, tkNone, nil, _DeleteRecord);
    DefineMethod('OpenDataModel', 1, tkNone, nil, _OpenDataModel);
    DefineMethod('RefreshDataModel', 0, tkNone, nil, _RefreshDataModel);
  end;
end;

procedure TSSDataModelSO._AppendRecord(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSADODataModel(CurrentObject).AppendRecord;
  end;
end;

procedure TSSDataModelSO._ApplyModify(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSADODataModel(CurrentObject).ApplyModify;
  end;
end;

procedure TSSDataModelSO._CancelModify(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSADODataModel(CurrentObject).CancelModify;
  end;
end;

procedure TSSDataModelSO._CloseDataModel(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSADODataModel(CurrentObject).CloseDataModel;
  end;
end;

procedure TSSDataModelSO._DeleteRecord(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSADODataModel(CurrentObject).DeleteRecord;
  end;
end;

procedure TSSDataModelSO._GetDataSet(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(Integer(TSSADODataModel(CurrentObject).GetDataSet.GetObjectInstance));
  end;
end;

procedure TSSDataModelSO._GetDataSource(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(Integer(TSSADODataModel(CurrentObject).GetDataSource));
  end;
end;

procedure TSSDataModelSO._IsAutoOpen(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSADODataModel(CurrentObject).IsAutoOpen);
  end;
end;

procedure TSSDataModelSO._IsReadOnly(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSADODataModel(CurrentObject).IsReadOnly);
  end;
end;

procedure TSSDataModelSO._OpenDataModel(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSADODataModel(CurrentObject).OpenDataModel(GetInputArgAsString(0));
  end;
end;

procedure TSSDataModelSO._RefreshDataModel(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSADODataModel(CurrentObject).RefreshDataModel;
  end;
end;

{ TSSDatabaseDriverSO }

procedure TSSDatabaseDriverSO.Init;
begin
  inherited;
  with Scripter.AddDelphiClass(TSSADODatabaseDriver) do
  begin
    DefineMethod('ExecuteProcedure', 3, tkInteger, nil, _ExecuteProcedure);
    DefineMethod('ExecuteSQL', 1, tkInteger, nil, _ExecuteSQL);
    DefineMethod('Query', 1, tkClass, nil, _Query);
    DefineMethod('QueryByModifiable', 1, tkClass, nil, _QueryByModifiable);
    DefineMethod('CommitTransaction', 0, tkNone, nil, _CommitTransaction);
    DefineMethod('RollbackTransaction', 0, tkNone, nil, _RollbackTransaction);
    DefineMethod('StartTransaction', 0, tkNone, nil, _StartTransaction);
    DefineMethod('InitObject', 0, tkNone, nil, _InitObject);
  end;
end;

procedure TSSDatabaseDriverSO._CommitTransaction(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSADODatabaseDriver(CurrentObject).CommitTransaction;
  end;
end;

procedure TSSDatabaseDriverSO._ExecuteProcedure(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(TSSADODatabaseDriver(CurrentObject).ExecuteProcedure(GetInputArgAsString(0), GetInputArg(1)));
  end;
end;

procedure TSSDatabaseDriverSO._ExecuteSQL(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSADODataBaseDriver(CurrentObject).ExecuteSQL(GetInputArgAsString(0));
    //    TSSRecord(CurrentObject).AppendValue(GetInputArgAsString(0), GetInputArgAsString(1));
  end;
end;

procedure TSSDatabaseDriverSO._InitObject(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSADODataBaseDriver(CurrentObject).InitObject;
  end;
end;

procedure TSSDatabaseDriverSO._Query(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(Integer(TSSADODatabaseDriver(CurrentObject).Query(GetInputArgAsString(0)).GetObjectInstance));
  end;
end;

procedure TSSDatabaseDriverSO._QueryByModifiable(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(Integer(TSSADODatabaseDriver(CurrentObject).QueryByModified(GetInputArgAsString(0)).GetObjectInstance));
  end;
end;

procedure TSSDatabaseDriverSO._RollbackTransaction(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSADODatabaseDriver(CurrentObject).RollbackTransaction;
  end;
end;

procedure TSSDatabaseDriverSO._StartTransaction(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    TSSADODatabaseDriver(CurrentObject).StartTransaction;
  end;
end;

{ TSSScriptBusinessObjectContextSO }

procedure TSSScriptBusinessObjectContextSO.Init;
begin
  inherited;
  with Scripter.AddDelphiClass(TSSScriptBusinessObjectContext) do
  begin
    DefineMethod('GetDatabase', 0, tkClass, nil, _GetDatabase);
    DefineMethod('GetParameters', 0, tkClass, nil, _GetParameters); //ISSADODatabaseDriver
  end;
end;

procedure TSSScriptBusinessObjectContextSO._GetDatabase(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(Integer((TSSScriptBusinessObjectContext(CurrentObject).GetDatabase as ISSADODatabaseDriver).GetObjectInstance));
  end;
end;

procedure TSSScriptBusinessObjectContextSO._GetParameters(AMachine: TatVirtualMachine);
begin
  with AMachine do
  begin
    ReturnOutputArg(Integer(TSSScriptBusinessObjectContext(CurrentObject).GetParameters.GetObjectInstance));
  end;
end;

end.
